import { mock } from "mockjs";
import { Author, Post } from "../models/models";

export class FakeSource {

    private static instance: FakeSource;

    static getInstance(): FakeSource {
        if (!FakeSource.instance) {
            FakeSource.instance = new FakeSource();
        }
        return this.instance;
    }

    authors: Author[];
    posts: Post[];

    private constructor() {
        this.authors = mock({
            'authors|10': [{
                'id|+1': 1,
                'firstName': '@cfirst',
                'lastName': '@clast',
            }]
        }).authors;
        this.posts = mock({
            'posts|100': [{
                'id|+1': 1,
                'title': '@ctitle',
                'author': {
                    'id|1-10': 1,
                },
                'votes': 1
            }]
        }).posts;
    }
}